Skip to content

Feature/matern adaptive#214

Merged
Jammy2211 merged 12 commits intomainfrom
feature/matern_adaptive
Feb 13, 2026
Merged

Feature/matern adaptive#214
Jammy2211 merged 12 commits intomainfrom
feature/matern_adaptive

Conversation

@Jammy2211
Copy link
Owner

This pull request introduces a new adaptive regularization scheme based on a Matérn kernel that adapts to pixel brightness, along with supporting infrastructure for efficient computation and testing. The main focus is to enable more flexible, data-driven regularization in pixelized inversions, particularly for use cases that benefit from spatially adaptive smoothing. Additionally, several utility and interface improvements were made to support the new regularization and enhance backend compatibility.

New adaptive Matérn kernel regularization:

  • Added MaternAdaptiveBrightnessKernel class in matern_adaptive_brightness_kernel.py, which implements a Matérn kernel regularization scheme where per-pixel weights adapt to the reconstructed brightness, enabling spatially varying smoothing. Includes methods for constructing the covariance matrix and computing weights, as well as detailed documentation.
  • Registered the new regularization class in the module's __init__.py for import.
  • Added comprehensive unit tests for the new regularization in test_matern_adaptive_brightness_kernel.py.

Backend and kernel improvements:

  • Refactored the Matérn kernel implementation to use a backend-agnostic gamma function (gamma_xp), ensuring compatibility with both NumPy and JAX. [1] [2]
  • Relaxed type casting in MaternKernel to allow for non-float parameters, improving flexibility and backend support.

Delaunay triangulation enhancements for Matérn regularization:

  • Added minimal Delaunay triangulation functions (scipy_delaunay_matern, jax_delaunay_matern) optimized for Matérn regularization, returning only the necessary information for downstream computation.
  • Updated the Delaunay interface logic to optionally skip Voronoi area calculations for cases where only minimal triangulation is needed, controlled by a new skip_areas flag. [1] [2]
  • Added the skip_areas flag to the Preloads class to allow this optimization to be configured. [1] [2]

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request introduces a new adaptive regularization scheme (MaternAdaptiveBrightnessKernel) that combines Matérn kernel-based regularization with brightness-adaptive weights, enabling spatially varying smoothness in pixelized inversions. The implementation is designed to work with both NumPy and JAX backends and includes optimizations for Delaunay triangulation when area calculations are not needed.

Changes:

  • Added MaternAdaptiveBrightnessKernel class with brightness-adaptive weighting for Matérn regularization
  • Introduced backend-agnostic gamma_xp function and relaxed type constraints in MaternKernel for improved backend compatibility
  • Added minimal Delaunay triangulation functions and skip_areas flag to optimize performance when Voronoi areas are not required

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
autoarray/inversion/regularization/matern_adaptive_brightness_kernel.py New adaptive Matérn regularization class with brightness-dependent weights and weighted covariance matrix construction
autoarray/inversion/regularization/__init__.py Registered the new MaternAdaptiveBrightnessKernel class for import
autoarray/inversion/regularization/matern_kernel.py Added backend-agnostic gamma_xp function and relaxed type casting for scale/nu parameters
autoarray/structures/mesh/delaunay_2d.py Added minimal Delaunay functions for Matérn usage and implemented skip_areas flag logic
autoarray/preloads.py Added skip_areas parameter to control Delaunay area computation
autoarray/structures/arrays/kernel_2d.py Fixed parameter annotation spacing
test_autoarray/inversion/regularizations/test_matern_adaptive_brightness_kernel.py Comprehensive tests for the new regularization scheme

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

linear_light_profile_blurred_mapping_matrix=None,
use_voronoi_areas: bool = True,
areas_factor: float = 0.5,
skip_areas: bool = False,
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The newly added skip_areas parameter is not documented in the Parameters section of the Preloads docstring. Please add documentation explaining what this parameter controls, when it should be set to True, and how it affects the Delaunay triangulation computation (specifically that it skips Voronoi area calculations and split point computations).

Copilot uses AI. Check for mistakes.
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

coefficient
The regularization coefficient which controls the degree of smooth of the inversion reconstruction.
scale
The typical scale of the exponential regularization pattern.
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter description refers to "exponential regularization pattern" but this class implements a Matérn kernel regularization. The description should refer to "Matérn regularization pattern" for accuracy. While the parent class has the same issue, it should be corrected in this new class.

Suggested change
The typical scale of the exponential regularization pattern.
The typical scale of the Matérn regularization pattern.

Copilot uses AI. Check for mistakes.
Comment on lines +29 to +30
mesh_grid = aa.m.MockMeshGrid(neighbors=neighbors, neighbors_sizes=neighbors_sizes)

Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variable mesh_grid is not used.

Suggested change
mesh_grid = aa.m.MockMeshGrid(neighbors=neighbors, neighbors_sizes=neighbors_sizes)

Copilot uses AI. Check for mistakes.
Jammy2211 and others added 4 commits February 13, 2026 12:56
…kernel.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…kernel.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…kernel.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI commented Feb 13, 2026

@Jammy2211 I've opened a new pull request, #215, to work on those changes. Once the pull request is ready, I'll request review from you.

Jammy2211 and others added 3 commits February 13, 2026 12:56
…brightness_kernel.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
… parameters

Co-authored-by: Jammy2211 <23455639+Jammy2211@users.noreply.github.com>
Document skip_areas parameter in Preloads docstring
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Jammy2211 and others added 2 commits February 13, 2026 13:30
…kernel.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Jammy2211 Jammy2211 merged commit b2dd830 into main Feb 13, 2026
8 checks passed
@Jammy2211 Jammy2211 deleted the feature/matern_adaptive branch February 13, 2026 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants